const jwt = require("jsonwebtoken");
const { SECRET } = require("./private");
// 解密jwt，用于把token解析成用户的 uid
function getLoginUserFromJWT(req) {
  const token = String(req.headers.authorization).split(" ").pop();
  const { uid } = jwt.verify(token, SECRET);
  return uid;
}

module.exports = {
  getLoginUserFromJWT,
};
